package com.aigc.txt2img.utils;

import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public class JsonUtil {

    /**
     * GsonToString(data,FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
     * @param data
     * @param policy
     * @return
     */
    public static String GsonToString(Object data, FieldNamingPolicy policy ) {
        GsonBuilder gsonBuilder = new GsonBuilder();
        gsonBuilder.setFieldNamingPolicy(policy);
        Gson gson = gsonBuilder.create();
        return gson.toJson(data);
    }
}
